<template>
  <div id="userCenter">
    <div class="userHead">
      <div class="portrait">
        <img :src="book">
      </div>
      <router-link tag="div" :to="{name: 'balance',query:{status: '1'}}" class="name">
        <p>{{name}}</p>
        <p>{{balance}}</p>
        <p>书币余额</p>
      </router-link>
      <router-link tag="div" :to="{name: 'balance',query:{status: '2'}}" class="name balance">
        <p>&emsp;</p>
        <p>{{commission}}</p>
        <p>佣金余额</p>
      </router-link>
    </div>
    <div class="usermenu">
      <router-link :to="'Recharge'" tag="div" class="box">
        <img src="../assets/image/wallet.png">
        <div class="item">
          <span>钱包</span>
          <button>充值</button>
        </div>
      </router-link>
      <router-link :to="{name: 'chargeLog',query:{status: '1'}}" tag="div" class="box">
        <img src="../assets/image/consume.png">
        <div class="item">
          <span>消费充值记录</span>
          <i class="iconfont icon-qianjinxiayige"></i>
        </div>
      </router-link>
      <router-link :to="{name: 'chargeLog',query:{status: '2'}}" tag="div" class="box">
        <img src="../assets/image/balance.png">
        <div class="item">
          <span>佣金记录</span>
          <i class="iconfont icon-qianjinxiayige"></i>
        </div>
      </router-link>
      <router-link :to="'bookOrder'" tag="div" class="box">
        <img src="../assets/image/bookall.png">
        <div class="item">
          <span>我的书籍</span>
          <i class="iconfont icon-qianjinxiayige"></i>
        </div>
      </router-link>
      <router-link :to="'recommend'" tag="div" class="box">
        <img src="../assets/image/recommend.png">
        <div class="item">
          <span>我的推荐</span>
          <i class="iconfont icon-qianjinxiayige"></i>
        </div>
      </router-link>
      <router-link :to="'invitingFriends'" tag="div" class="box">
        <img src="../assets/image/invite.png">
        <div class="item">
          <span>邀请</span>
          <i class="iconfont icon-qianjinxiayige"></i>
        </div>
      </router-link>
      <router-link :to="'serviceCenter'" tag="div" class="box">
        <img src="../assets/image/service.png">
        <div class="item">
          <span>客服反馈</span>
          <i class="iconfont icon-qianjinxiayige"></i>
        </div>
      </router-link>
    </div>
    <com-foot :select="3"></com-foot>
  </div>
</template>

<script>
export default {
  name: "userCenter",
  data() {
    return {
      book: '',
      name: "",
      balance: "0",
      commission: "0"
    };
  },

  computed: {},

  created() {},

  mounted() {
    this.loading();
  },

  methods: {
    loading() {
      this.axios
        .post("user/index", {
          token: this.token()
        })
        .then(({ data }) => {
          console.log(data);
          if (data.code === "200") {
            this.book = data.data.user_avat;
            this.name = data.data.user_name;
            this.balance = data.data.user_account;
            this.commission = data.data.commission;
          } else if (data.code === "201") {
            this.$bus.$emit("toast", data.msg);
          }
        })
        .catch(function(error) {
          console.log(error);
        });
    }
  }
};
</script>
<style lang='scss' scoped>
#userCenter {
  background: url("../assets/image/usercenter.png") no-repeat;
  background-size: 750px 384px;
  background-color: #fff;
  .userHead {
    margin: 110px 32px 0;
    height: 130px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    .portrait {
      width: 130px;
      height: 130px;
      background: rgba(216, 216, 216, 1);
      border: 2px solid;
      border-radius: 65px;
      overflow: hidden;
      img {
        width: 100%;
      }
    }
    .name {
      margin-left: 30px;
      color: #222;
      p:nth-of-type(1) {
        font-size: 28px;
        line-height: 60px;
      }
      p:nth-of-type(2) {
        font-size: 32px;
        line-height: 40px;
        font-weight: 600;
      }
      p:nth-of-type(3) {
        font-size: 22px;
        line-height: 40px;
      }
    }
    .balance {
      margin-left: 80px;
      p:nth-of-type(1) {
        font-size: 28px;
        line-height: 60px;
      }
      p:nth-of-type(2) {
        font-size: 32px;
        line-height: 40px;
        font-weight: 600;
      }
      p:nth-of-type(3) {
        font-size: 22px;
        line-height: 40px;
      }
    }
  }
  .usermenu {
    margin-top: 50px;
    padding: 0 32px;
    box-sizing: border-box;
    background-color: #fff;
    .box {
      display: flex;
      justify-content: space-between;
      align-items: center;
      img {
        display: block;
        width: 6%;
        height: 6%;
      }
    }
    .item {
      width: 616px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1Px solid rgba(238, 238, 238, 1);
      line-height: 100px;
      span {
        // width: 120px;
        text-align: left;
      }
      .iconfont {
        color: #ddd;
        font-size: 40px;
      }
    }
    .item:nth-of-type(1) {
      button {
        width: 100px;
        height: 48px;
        font-size: 22px;
        font-weight: 400;
        color: #fff;
        background: rgba(236, 2, 2, 1);
        border-radius: 6px;
      }
    }
  }
}
</style>